package com.levenx.web;

import com.levenx.validdate.ValidateCodeProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * Created by Administrator on 2019/6/10.
 */
@Controller
public class ValidateCodeController {

    @Autowired
    private Map<String,ValidateCodeProcessor> validateCodeProcessors;

    /**
     * 获取验证码图片
     * @param request
     * @param response
     * @throws IOException
     */
    @GetMapping("/code/{type}")
    public void cratedCode(@PathVariable String type, HttpServletRequest request, HttpServletResponse response) throws Exception {
        validateCodeProcessors.get(type+"ValidateCodeProcessor").create(request,response);
    }

}
